package com.vanzo.tisen.agingtest;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by tisen on 2017/8/16.
 */

public class AgingApplication extends Application {

    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;

    @Override
    public void onCreate() {
        super.onCreate();
        sharedPreferences = getSharedPreferences(SharedString.SHARE_NAME, MODE_PRIVATE);
        editor = sharedPreferences.edit();
    }

    public void setAgingRunning(boolean isRunning) {
        editor.putBoolean(SharedString.AGING_RUNNING, isRunning);
        if(!isRunning){
            editor.putBoolean(SharedString.IS_CAMERA,false);
            editor.putBoolean(SharedString.IS_FRONT_CAMERA,false);
            editor.putBoolean(SharedString.IS_HANDSET,false);
            editor.putBoolean(SharedString.IS_LCD,false);
            editor.putBoolean(SharedString.IS_MIC,false);
            editor.putBoolean(SharedString.IS_REBOOT,false);
            editor.putBoolean(SharedString.IS_SPEAKER,false);
            editor.putBoolean(SharedString.IS_VIBRATOR,false);
        }
        editor.commit();
    }


    public void setAgingTime(long time) {
        editor.putLong(SharedString.AGING_TIME, time);
        editor.commit();
    }

    public void setRoundTime(long time) {
        editor.putLong(SharedString.ROUND_TIME, time);
        editor.commit();
    }

    public boolean getAgingRunning() {
        return sharedPreferences.getBoolean(SharedString.AGING_RUNNING,false);
    }

    public long getAgingTime() {
        return sharedPreferences.getLong(SharedString.AGING_TIME, 120);
    }

    public long getRoundTime() {
        return sharedPreferences.getLong(SharedString.ROUND_TIME, 20);
    }

    public void setDeviceTest(String key,boolean isTest){
        editor.putBoolean(key,isTest);
        editor.commit();
    }
    public boolean getDeviceTest(String key){
        return sharedPreferences.getBoolean(key,false);
    }
    public void setHasReboot(boolean isRunning) {
        editor.putBoolean(SharedString.HAS_REBOOT, isRunning);
        editor.commit();
    }
    public boolean getHasReboot() {
        return sharedPreferences.getBoolean(SharedString.HAS_REBOOT,false);
    }
}
